package com.yyfax.ph.common.imageselector.bean;

import android.os.Parcel;
import android.os.Parcelable;

/**
 * Title: ImageBean Description: Company: YYLending(YouJingPuHui)
 *
 * @author XiongYuFeng
 *         date 2016年8月15日 下午2:28:15
 */
public class ImageBean implements Parcelable {
	/**
	 * 0：上传中 1：上传成功 -1：上传失败
	 */
	public static final int STATUS_ING = 0;
	/**
	 * 0：上传中 1：上传成功 -1：上传失败
	 */
	public static final int STATUS_SUCCESS = 1;
	/**
	 * 0：上传中 1：上传成功 -1：上传失败
	 */
	public static final int STATUS_FAIL = -1;

	public String imageId;
	public String originalPath;
	public String newPath;
	//public boolean uploaded;
	/**
	 * 0：上传中 1：上传成功 -1：上传失败
	 */
	public int status;

	public ImageBean() {
		super();
	}

	public ImageBean(String originalPath, String newPath) {
		super();
		this.originalPath = originalPath;
		this.newPath = newPath;
	}

	public ImageBean(String imageId, String originalPath, String newPath) {
		super();
		this.imageId = imageId;
		this.originalPath = originalPath;
		this.newPath = newPath;
	}

	@Override
	public String toString() {
		return "ImageBean{" +
				"imageId='" + imageId + '\'' +
				", originalPath='" + originalPath + '\'' +
				", newPath='" + newPath + '\'' +
				", status=" + status +
				'}';
	}

	@Override
	public boolean equals(Object o) {
		if (this == o) return true;
		if (o == null || getClass() != o.getClass()) return false;

		ImageBean imageBean = (ImageBean) o;

		return newPath != null ? newPath.equals(imageBean.newPath) : imageBean.newPath == null;
	}

	@Override
	public int hashCode() {
		return originalPath != null ? originalPath.hashCode() : 0;
	}

	@Override
	public int describeContents() {
		return 0;
	}

	@Override
	public void writeToParcel(Parcel dest, int flags) {
		dest.writeString(this.imageId);
		dest.writeString(this.originalPath);
		dest.writeString(this.newPath);
		dest.writeInt(this.status);
	}

	protected ImageBean(Parcel in) {
		this.imageId = in.readString();
		this.originalPath = in.readString();
		this.newPath = in.readString();
		this.status = in.readInt();
	}

	public static final Creator<ImageBean> CREATOR = new Creator<ImageBean>() {
		@Override
		public ImageBean createFromParcel(Parcel source) {
			return new ImageBean(source);
		}

		@Override
		public ImageBean[] newArray(int size) {
			return new ImageBean[size];
		}
	};

	public boolean isUploaded(){
		return STATUS_SUCCESS == status;
	}
}
